package thread;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/25
 * Time:20:37
 **/
public class ThreadDemo2 {
    /**
     * 打印"AABBCCDD"
     * @param args
     * @throws InterruptedException
     */

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                String str = "ABCD";
                for (char a:str.toCharArray()) {
                    System.out.print(a);
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }

        });

        Thread t1 = new Thread(thread);
        Thread t2 = new Thread(thread);
        t1.start();
        t2.start();
    }
}
